#pragma once

#include <string>
#include <map>
#include <mutex>
#include "BondInfo.h"

class S_BONDLIB_EXPORT CBankQuote
{
public:
	std::map<std::string, BKQUOTE> m_map;	//companyid,bkquote
};

class S_BONDLIB_EXPORT BKQUOTEModifier
{

};

class S_BONDLIB_EXPORT CBondBankRep
{
public:
	class S_BONDLIB_EXPORT ApplyCallback
	{
	public:
		virtual bool DoAccess(const BKQUOTE& quote){ return false; }//true表示可继续,false表示中断
		virtual bool DoModify(BKQUOTE& quote){ return false; }//true表示可继续,false表示中断
	};
	CBondBankRep();
	virtual ~CBondBankRep();
	bool	Clear( );
	bool	Clear(int clrFlag);

	int		GetSize()const;
	int		GetBytes(int mode=0)const;
	int		GetItemSize()const{ return sizeof(XCQUOTE); }
	const char* GetName()const;

	bool	InsertBankRep(const BKQUOTE& newElement );
	bool	GetBankRepByKey(const std::string& sKey,BKQUOTE &stRep);

	void	ApplyAccess(bool all,const std::string& sKey, ApplyCallback* callback);
	void	ApplyModify(bool all,const std::string& sKey, ApplyCallback* callback);
protected:
	CBankQuote				m_RepMap;
	std::mutex		m_lock;
};
